
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-language" content="cs" />
<meta name="robots" content="all,follow" />
<meta name="description" content="..." />
<meta name="keywords" content="..." />

<link rel="stylesheet" media="screen,projection" type="text/css" href="<c:url value='/css/mainForOtherPages.css' />" />
<link rel="stylesheet" media="print" type="text/css" href="<c:url value='/css/print.css' />" />
<link rel="stylesheet" media="aural" type="text/css" href="<c:url value='/css/aural.css' />" />
<link rel="stylesheet" type="text/css" href="<c:url value='/css/tcal.css' />" />
<link rel="stylesheet" type="text/css" href="<c:url value='/css/button.css' />" />
<link rel="stylesheet" type="text/css" href="<c:url value='/css/viewresource.css'/>" />
<link rel="stylesheet" type="text/css" href="<c:url value='/css/uploadPopup.css' />" />
<link rel="stylesheet" type="text/css" href="<c:url value='/css/jquery.qtip.css' />" />
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/json/json-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/connection/connection-min.js"></script>
<script type="text/javascript" src="<c:url value='/js/jquery.qtip.js' />"></script>
<script type="text/javascript" src="<c:url value='/js/userResourceList.js' />"></script>
<script type="text/javascript" src="<c:url value='/js/tooltips.js' />"></script>
<script type="text/javascript">
	putUserResources("<c:url value='/resourceList'/>");
</script>
<title>ProjectBox</title>
</head>

<body id="www-url-cz">

	<!-- Main -->
	<div id="main" class="box">

		<!-- Header -->
		<div id="header">

			<!-- Logotyp -->
			<img alt="" src="<c:url value='/design/logo.png'/>" class="logo" />
			<hr class="noscreen" />

			<!-- Quick links -->
			<div class="noscreen noprint">
				<p>
					<em>Quick links: <a href="#content">content</a>, <a
						href="#tabs">navigation</a>, <a href="#search">search</a>.
					</em>
				</p>
				<hr />
			</div>

			<!-- Search -->
			<div id="search" class="noprint">
				<form action="" method="get">
					<fieldset>
						<legend>Search</legend>
						<label><span class="noscreen">Find:</span> <span
							id="search-input-out"><input type="text"
								id="search-input" name="search-input" size="30" placeholder="Search Projects" onclick="javascript:emptyTopSearchBox()"/> </span> </label> 
								<input type="image" src="<c:url value='/design/search_submit.gif' />" id="search-submit" ALT="Submit Form" border="0" value=”Submit”/>

					</fieldset>
				</form>
			</div>
			<!-- /search -->

		</div>
		<!-- /header -->

		<!-- Main menu (tabs) -->
		<div id="tabs" class="noprint">
			<h3 class="noscreen">Navigation</h3>
			<ul class="box">
				<li><a href="<c:url value='/announcement'/>">Announcements<span
						class="tab-l"></span><span class="tab-r"></span></a></li>
				<!-- Active -->
				<li id="active"><a href="<c:url value='/myproject'/>">Projects<span
						class="tab-l"></span><span class="tab-r"></span></a></li>
				<li><a href="<c:url value='/search'/>">Search<span
						class="tab-l"></span><span class="tab-r"></span></a></li>
				<li><a href="<c:url value='/rule'/>">Rules<span
						class="tab-l"></span><span class="tab-r"></span></a></li>
			</ul>

			<div class="f-right"
				style="margin-right: 20px; margin-bottom: 20px; font-weight: bold; color: #FF9000;">
				Hi, ${user.firstName} ${user.lastName} | <a
					href="<c:url value='/logout' />">Logout</a>
			</div>

			<hr class="noscreen" />
		</div>
		<!-- /tabs -->

		<!-- Page (2 columns) -->
		<div id="page" class="box">
			<div id="page-in" class="box">

				<!-- /strip -->

				<!-- Content -->
				<div id="content">

					<!-- Article -->
					<div class="article">

						<h2>
							<span>${project.name}</span>
						</h2>
						<table class="zeroborder_table" border="0" bordercolor="#FFFFFF">
							<tr>
								<td class="zeroborder_table" width="430" height="30"><strong>
										<a href="<c:url value='/project/${project.id}/' />">${project.name}</a>
										<c:choose>
											<c:when test="${folders != null}">
												<c:forEach var="tfolder" items="${traceFolders}"
													varStatus="counter">
            			> <a
														href="<c:url value='/project/${project.id}/${tfolder.id}/' />">${tfolder.name}</a>
												</c:forEach>
											</c:when>
										</c:choose> <c:choose>
											<c:when test="${folder != null}">
            		> ${folder.name}
            	</c:when>
										</c:choose>
								</strong></td>
								<c:choose>
									<c:when test="${folder != null}">
										<td class="zeroborder_table" height="30"><a
											href="javascript:newFolder(${project.id}, ${folder.id}, '<c:url value='/images' />')"><img
												id="createFolder"
												src="<c:url value='/images/newfolder.png' />"
												alt="New Folder" height="25" width="25" /></a></td>
									</c:when>
									<c:otherwise>
										<td class="zeroborder_table" height="30"><a
											href="javascript:newFolder(${project.id}, 0, '<c:url value='/images' />')"><img
												id="createFolder"
												src="<c:url value='/images/newfolder.png' />"
												alt="New Folder" height="25" width="25" /></a></td>
									</c:otherwise>
								</c:choose>
								<td class="zeroborder_table" height="30"><a
									href="javascript:popup('Upload')"><img id="uploadFile"
										src="<c:url value='/images/upload.png' />" alt="Upload"
										height="25" width="25" /></a></td>
							</tr>
						</table>
						<table class="zeroborder_table" width="483px" style='table-layout: fixed'>
							<tbody id='contentList'>
								<c:choose>
									<c:when test="${folders != null}">
										<c:forEach var="folder" items="${folders}" varStatus="counter">
											
											<tr>

												<td class="zeroborder_nowrap" ><a
													href="<c:url value='/project/${project.id}/${folder.id}/' />"><img
														src="<c:url value='/images/folder.png' />" alt="Folder"
														height="20" width="18" /></a></td>
												<td class="zeroborder_wrap_name" valign="middle"
													align="absmiddle">
													<div align="left" align="absmiddle">
														<a id="text${counter.index}"
															href="<c:url value='/project/${project.id}/${folder.id}/' />">${folder.name}</a>
														<input type="hidden" id="textbox${counter.index}"
															onchange="changeName('text${counter.index}','textbox${counter.index}', ${project.id}, ${folder.id} , 0);"
															class="finput" />
													</div>
												</td>
												<td class="zeroborder_wrap_type" align="left" align="absmiddle">
													<div align="left">Folder</div>
												</td>

												<td class="zeroborder_wrap_date"><div align="left"
														align="absmiddle">-</div></td>
												<td class="zeroborder_wrap_author"><div align="left">
														-</div></td>
												<c:choose>
													<c:when test="${project.mid == user.id}">
														<td class="zeroborder_nowtop"><div align="left">
																<a
																	href="javascript: clickRename('text${counter.index}','textbox${counter.index}');"><img
																	class="renameF"
																	src="<c:url value='/images/rename.png' />" alt="Rename"
																	width="16" height="19" align="absmiddle" /></a>
															</div></td>
														<td class="zeroborder_nowtop"><div align="left">
																<a
																	href="<c:url value='/project/${project.id}/${folder.id}/deleteFolder' />"><img
																	class="deleteF"
																	src="<c:url value='/images/trash.png' />" alt="Delete"
																	width="18" height="20" align="absmiddle" /></a>
															</div></td>
													</c:when>
													<c:otherwise>
														<td class="zeroborder_nowrap"><div align="left"></div></td>
														<td class="zeroborder_nowrap"><div align="left"></div></td>
													</c:otherwise>
												</c:choose>
												<td class="zeroborder_nowrap"><div align="left"></div></td>
											</tr>
										</c:forEach>
									</c:when>
								</c:choose>

								<c:choose>
									<c:when test="${resources != null}">
										<c:forEach var="resource" items="${resources}"
											varStatus="counter">
											<tr>
												<td class="zeroborder_nowrap"><a
													href="<c:url value='/project/${project.id}/download?rid=${resource.id}' />"><img
														src="<c:url value='/images/${resource.type}.png' />"
														alt="Resource" height="20" width="18" /></a>
												</td>
												
												<td class="zeroborder_wrap_name" valign="middle"
													align="absmiddle"><div align="left" align="absmiddle">
														<a
															href="<c:url value='/project/${project.id}/download?rid=${resource.id}' />"><span
															id="reso${counter.index}">${resource.name}</span></a>
														<c:choose>
															<c:when test="${folder != null}">
																<input type="hidden" id="resobox${counter.index}"
																	onchange="changeName('reso${counter.index}','resobox${counter.index}', ${project.id}, ${folder.id}, ${resource.id});"
																	class="finput" />
															</c:when>
															<c:otherwise>
																<input type="hidden" id="resobox${counter.index}"
																	onchange="changeName('reso${counter.index}','resobox${counter.index}', ${project.id}, 0, ${resource.id});"
																	class="finput" />
															</c:otherwise>
														</c:choose>
													</div>
												</td>

												<td class="zeroborder_wrap_type" align="left" align="absmiddle">
													<span id="type${counter.index}" align="left">${fn:substring(resource.type,0,fn:indexOf(resource.type,"."))}
													<font id="fext${counter.index}" color="grey">${fn:substring(resource.type,fn:indexOf(resource.type,".")+1,fn:length(resource.type))}</font> </span>
													<script>
         												var fext = document.getElementById("fext${counter.index}");
         													if (fext.innerHTML == "file") {
         													fext.innerHTML = "";
         												}
         											</script>
												</td>

												<td class="zeroborder_wrap_date"><div align="left"
														align="absmiddle">
														<script language="Javascript">
								nd = new Date(${resource.timeModified});
								var month = nd.getMonth() + 1;
								var day = nd.getDate();
								var year = nd.getFullYear();
								var hour = nd.getHours() % 12;
								var min = nd.getMinutes();
								document.write(month + "/" + day + "/" + year + "<br/>");
								
								if (hour == 0) {
									document.write("12");
								} else {
									document.write(hour);
								}
								
								document.write(":");
								
								if (min < 10) {
									document.write("0" + min);
								} else {
									document.write(min);
								}
								
								if (nd.getHours() >= 12) {
									document.write(" PM");
								} else {
									document.write(" AM");
								}
							</script>
													</div></td>

												<td class="zeroborder_wrap_author"><div align="left">${resource.owner.firstName
														}</div></td>
												<td class="zeroborder_nowtop"><div align="left">
														<a
															href="<c:url value='/project/${project.id}/download?rid=${resource.id}' />"><img
															class="downloadFile"
															src="<c:url value='/images/download.png' />"
															alt="Download" width="18" height="20" align="absmiddle" /></a>
													</div></td>

												<c:choose>
													<c:when
														test="${resource.uid == user.id or project.mid == user.id}">
														<td class="zeroborder_nowtop" align="left"><div
																align="left">
																<a
																	href="javascript: clickRename('reso${counter.index}','resobox${counter.index}');">
																	<img class="renameF"
																	src="<c:url value='/images/rename.png' />" alt="Rename"
																	width="16" height="19" />
																</a>
															</div></td>
														<c:choose>
															<c:when test="${folder != null}">
																<td class="zeroborder_nowtop"><div align="left">
																		<a
																			href="<c:url value='/project/${project.id}/${folder.id}/delete?rid=${resource.id}' />">
																			<img class="deleteF"
																			src="<c:url value='/images/trash.png' />"
																			alt="Delete" width="18" height="20" align="absmiddle" />
																		</a>
																	</div></td>
															</c:when>
															<c:otherwise>
																<td class="zeroborder_nowtop"><div align="left">
																		<a
																			href="<c:url value='/project/${project.id}/delete?rid=${resource.id}' />">
																			<img class="deleteF"
																			src="<c:url value='/images/trash.png' />"
																			alt="Delete" width="18" height="20" align="absmiddle" />
																		</a>
																	</div></td>
															</c:otherwise>
														</c:choose>
													</c:when>
													<c:otherwise>
														<td class="zeroborder_nowrap"><div align="left"></div></td>
														<td class="zeroborder_nowrap"><div align="left"></div></td>
													</c:otherwise>
												</c:choose>
											</tr>
										</c:forEach>
									</c:when>
								</c:choose>
							</tbody>
						</table>

					</div>
					<hr class="noscreen" />
				</div>

				<!-- /content -->
				<!-- Right column -->
				<div id="col" class="noprint">
					<div id="col-in">

						<!-- About Me 
						<h3>
							<span>About Me</span>
						</h3>

						<div id="about-me">
							<strong>${user.firstName} ${user.lastName}</strong><br /> Age:
							26<br /> Dallas, TX<br />

						</div>-->
						<!-- /about-me 

						<hr class="noscreen" />-->

						<!-- Category -->
						<h3>Projects</h3>

						<ul id="category">
							<li><a href="<c:url value='/newproject' />">Create
									Project</a></li>
							<li><a href="<c:url value='/myproject' />">My Projects</a></li>
							<li><a href="<c:url value='/contribute' />">Contributed
									Projects</a></li>
							<li><a href="<c:url value='/project' />">Other Projects</a>
							</li>
						</ul>

						<hr class="noscreen" />

						<!-- Archive -->
						<h3>
							<span>Latest Resources</span>
						</h3>
					</div>
					<!-- /col-in -->
				</div>
				<!-- /col -->

			</div>
			<!-- /page-in -->
		</div>
		<!-- /page -->

		<!-- Footer -->
		<div id="footer">
			<div id="top" class="noprint">
				<p>
					<span class="noscreen">Back on top</span> <a href="#header"
						title="Back on top ^">^<span></span>
					</a>
				</p>
			</div>
			<hr class="noscreen" />

			<p id="createdby">
				created by <a href="http://www.nuvio.cz">Nuvio | Webdesign</a>
				<!-- DONÂ´T REMOVE, PLEASE! -->
			</p>
			<p id="copyright">
				&copy; 2012 <a href="mailto:mss.projectbox@gmail.com">ProjectBox
					Team</a>
			</p>
		</div>
		<!-- /footer -->

	</div>
	<!-- /main -->

	<div id="dialog-overlay"></div>
	<div id="dialog-box">
		<div class="dialog-content">
			<table class="zeroborder_table">
				<tr>
					<td class="zeroborder_table"><img
						src="<c:url value='/images/logoUpload.png' />" alt="Upload"
						height="50" width="50" /></td>
					<td class="zeroborder_table"><div id="popup_heading"
							font-size:50px>Upload to Project Box!</div></td>
				</tr>
			</table>
			<c:choose>
				<c:when test="${folder == null}">
					<form class="myform"
						action="<c:url value='/project/${project.id}/upload' />"
						method="post" enctype="multipart/form-data">
						<table class="zeroborder_table">
							<tr>
								<td class="zeroborder_table"><label for="file"><strong>Updload
											File</strong></label></td>
								<td class="zeroborder_table"><input type="file" name="file"
									id="file" size="24" class="checkFile" /></td>
							</tr>
							<tr>
								<td class="zeroborder_table"><label for="desc"><strong>Description</strong></label></td>
								<td class="zeroborder_table"><textarea rows="3" cols="28"
										name="desc" id="desc"></textarea></td>
							</tr>
							<tr>
								<td class="zeroborder_table"><input type="submit"
									name="submit" value="Upload" class="check" /></td>
								<td class="zeroborder_table"><a href="#" id="close"
									class="button">Close</a></td>
							</tr>
						</table>
					</form>

				</c:when>
				<c:otherwise>
					<form class="myform"
						action="<c:url value='/project/${project.id}/${folder.id}/upload' />"
						method="post" enctype="multipart/form-data">
						<table class="zeroborder_table">
							<tr>
								<td class="zeroborder_table"><label for="file"><strong>Updload
											File</strong></label></td>
								<td class="zeroborder_table"><input type="file" name="file"
									id="file" size="24" class="checkFile" /></td>
							</tr>
							<tr>
								<td class="zeroborder_table"><label for="desc"><strong>Description</strong></label></td>
								<td class="zeroborder_table"><textarea rows="3" cols="26"
										name="desc" id="desc"></textarea></td>
							</tr>
							<tr>
								<td class="zeroborder_table"><input type="submit"
									name="submit" value="Upload" class="check" /></td>
								<td class="zeroborder_table"><a href="#" id="close"
									class="button">Close</a></td>
							</tr>
						</table>
					</form>

				</c:otherwise>
			</c:choose>

		</div>
	</div>
	<script src="<c:url value='/js/resource.js' />" type="text/javascript"></script>
		<script type="text/javascript">
// Create the tooltips only on document load
$(document).ready(function() 
{	
	loadToolTips("<c:url value='/dummyUrl'/>");
});

</script>
</body>
</html>
